<?php

namespace App\V3\Api\Services;

use App\V3\Api\Models\VipSettingModel;

class VipSettingService
{
    //vip功能列表
    static public function index()
    {
        return VipSettingModel::orderBy('id', 'desc')->first();
    }

    //新建
    static public function add($data)
    {
        return VipSettingModel::insertGetId($data);
    }

    //修改
    static public function edit($data)
    {
        $info = VipSettingModel::where('id', $data['id'])->first();

        if(empty($info)) {
            return ['code' => 1, 'msg' => '目标信息不存在，请重试', 'data' => ''];
        }

        VipSettingModel::where('id', $data['id'])
            ->update($data);
        return ['code' => 0, 'msg' => 'success', 'data' => ''];
    }

    //详情
    static public function detail($id)
    {
        $info = VipSettingModel::where('id', $id)->first();

        if(empty($info)) {
            return ['code' => 1, 'msg' => '目标数据不存在，请刷新后重试', 'data' => ''];
        }

        return ['code' => 0, 'msg' => 'success', 'data' => $info];
    }
}
